package com.patterns.demo.memento;

/**
 * Author: SamGroves
 * <p>
 * Description:
 * <p>
 * Date: 2017/12/19
 */
public class Test {

    public static void main(String[] args) {

        // 创建原始类
        Original original = new Original("egg");

        // 创建备忘录
        Storage storage = new Storage(original.createMemento());

        // 修改原始类的状态
        System.out.println("初始状态为:" + original.getValue());
        original.setValue("dog");
        System.out.println("修改之后的状态为：" + original.getValue());

        // 恢复原始类的状态
        original.restoreMemento(storage.getMemento());
        System.out.println("恢复后的状态为:" + original.getValue());
    }
}
